import 'package:flutter/material.dart';
import 'package:flutter_dva_hooks/flutter_dva_hooks.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:todo_app/components/TextExt.dart';
import 'package:todo_app/layout/CustomCard.dart';
import 'package:todo_app/layout/Gaps.dart';
import 'package:todo_app/layout/Header.dart';
import 'package:todo_app/models/getters.dart';

class MeQrcodePage extends HookWidget {
  const MeQrcodePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var store = useDvaStore();
    var userId = store.rootState.system?.user!.id;
    var name = store.rootState.system?.user?.username;
    return Scaffold(
      appBar: const Header(title: "我的二维码"),
      body: Column(
        children: [
          CustomCard(
            padding: EdgeInsets.all(80.dp),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                QrImageView(
                  data: 'todoapp://user/$userId',
                  version: QrVersions.auto,
                  size: 200.dp,
                ),
                Gaps.vGap16,
                TextExt.desc(name ?? "")
              ],
            )
          )
        ],  
      )
    );
  }
}